<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-yellow sidebar-mini">
<section class="content-header">
    <h1>半成品库出入库记录</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm" class="form-horizontal">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group margin-bottom-none"
                                     style="margin-left:0px;margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        生产令编号
                                    </label>
                                    <label class="control-label">
                                        <input name="prodNo" class="form-control" type="text" maxlength="255"
                                               value=""
                                               placeholder="请输入生产令编号"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        项目名称
                                    </label>
                                    <label class="control-label">
                                        <input name="proName" class="form-control" type="text" maxlength="255"
                                               placeholder="请输入项目名称"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        部分
                                    </label>
                                    <label class="control-label">
                                        <input name="part" class="form-control" type="text" maxlength="255"
                                               placeholder="请输入部分"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        图号
                                    </label>
                                    <label class="control-label">
                                        <input name="drawNo" class="form-control" type="text" maxlength="255"
                                               placeholder="请输入图号"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        零件名称
                                    </label>
                                    <label class="control-label">
                                        <input name="drawName" class="form-control" type="text" maxlength="255"
                                               placeholder="请输入零件名称"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        材质
                                    </label>
                                    <label class="control-label">
                                        <input name="quality" class="form-control" type="text" maxlength="255"
                                               placeholder="请输入材质"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        规格
                                    </label>
                                    <label class="control-label">
                                        <input name="spec" class="form-control" type="text" maxlength="255"
                                               placeholder="请输入规格"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        库存地点
                                    </label>
                                    <label class="control-label">
                                        <input name="storeAddr" class="form-control" type="text" maxlength="255"
                                               placeholder="请输入库存地点"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        操作人
                                    </label>
                                    <label class="control-label">
                                        <input name="storageRegister" class="form-control" type="text" maxlength="255"
                                               placeholder="请输入操作人"/>
                                    </label>
                                </div>
                                <!--                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">-->
                                <!--                                    <label class="control-label">-->
                                <!--                                        质检意见-->
                                <!--                                    </label>-->
                                <!--                                    <label class="control-label">-->
                                <!--                                        <input name="checkOpinion" class="form-control" type="text" maxlength="255"-->
                                <!--                                               placeholder="请输入质检意见"/>-->
                                <!--                                    </label>-->
                                <!--                                </div>-->
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        类型
                                    </label>
                                    <label class="control-label">
                                        <select name="special" class="form-control">
                                            <option value="">全部</option>
                                            <option value="机械">机械</option>
                                            <option value="流体">流体</option>
                                            <option value="自动化">自动化</option>
                                            <option value="外观">外观</option>
                                        </select>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        操作类型
                                    </label>
                                    <label class="control-label">
                                        <select name="storeType" class="form-control">
                                            <option value="">全部</option>
                                            <option value="1">转储入库</option>
                                            <option value="2">派工出库</option>
                                            <option value="3">发货出库</option>
                                            <option value="4">转储退库</option>
                                            <option value="5">派工退库</option>
                                            <option value="6">发货退库</option>
                                        </select>
                                    </label>
                                </div>
                                <!--                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">-->
                                <!--                                    <label class="control-label">-->
                                <!--                                        记录类别-->
                                <!--                                    </label>-->
                                <!--                                    <label class="control-label">-->
                                <!--                                        <select name="recordType" class="form-control">-->
                                <!--                                            <option value="">全部</option>-->
                                <!--                                            <option value="1">正常</option>-->
                                <!--                                            <option value="2">冲单</option>-->
                                <!--                                        </select>-->
                                <!--                                    </label>-->
                                <!--                                </div>-->
                                <button id="btn-search" type="button" class="btn btn-success">
                                    搜索
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    let table;
    $(function () {
        /**
         * 加载列表
         */
        table = js.table.init({
            url: ctx + "transposition/halfStoreRecord/list",
            showColumns: true,
            showExport: true,
            uniqueId: 'ids',
            columns: [
                {
                    title: '序号', field: 'orderNo', width: '60',
                    formatter: function (value, row, index, field) {
                        var pageSize = table.bootstrapTable('getOptions').pageSize;
                        var pageNumber = table.bootstrapTable('getOptions').pageNumber;
                        return pageSize * (pageNumber - 1) + index + 1;
                    }
                },
                {
                    title: '生产令编号', field: 'prodNo', width: '110',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }

                    }
                },
                {
                    title: '项目名称', field: 'proName', width: '150',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }

                    }
                },
                {
                    title: '类型', field: 'special', width: '60',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }

                    }
                },
                {
                    title: '部分', field: 'part', width: '150',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }
                    }
                },
                {
                    title: '图号', field: 'drawNo', width: '200',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }
                    }
                },
                {
                    title: '零件名称', field: 'drawName',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }
                    }
                },
                {
                    title: '数量', field: 'drawNum', width: '90',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }
                    }
                }
                ,
                {
                    title: '单重（kg）', field: 'weight', width: '90',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }
                    }
                }
                ,
                {
                    title: '材质', field: 'quality', width: '90',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }
                    }
                }
                ,
                {
                    title: '规格', field: 'spec', width: '90',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }
                    }
                }
                ,
                {
                    title: '库存地点', field: 'storeAddr', width: '90',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }
                    }
                },
                {
                    title: '操作人', field: 'storageRegister', width: '90',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }
                    }
                },
                {
                    title: '登记日期', field: 'storageTime', width: '90',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }
                    }
                },
                // {
                //     title: '质检意见', field: 'checkOpinion', width: '90',
                //     formatter: function (value, row, index) {
                //         if (value != null) {
                //             return value;
                //         } else {
                //             return '--';
                //         }
                //     }
                // },
                {
                    title: '操作类型', field: 'storeType', width: '90',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            if (row.storeType === 1 && row.recordType == 1 && row.sourceType == 1) {
                                return '<label class="badge label-success">转储入库</label>';
                            } else if (row.storeType === 1 && row.recordType == 2 && row.sourceType == 1) {
                                return '<label class="badge label-danger">转储退库</label>';
                            } else if (value === 2 && row.recordType == 1 && row.sourceType == 2) {
                                return '<label class="badge label-success">派工出库</label>';
                            } else if (value === 2 && row.recordType == 2 && row.sourceType == 2) {
                                return '<label class="badge label-danger">派工退库</label>';
                            } else if (value === 2 && row.recordType == 1 && row.sourceType == 3) {
                                return '<label class="badge label-success">发货出库</label>';
                            } else if (value === 2 && row.recordType == 2 && row.sourceType == 2) {
                                return '<label class="badge label-danger">发货退库</label>';
                            }
                        } else {
                            return '--';
                        }
                    }
                }
                ,
                // {
                //     title: '记录类别', field: 'recordType', width: '90',
                //     formatter: function (value, row, index) {
                //         if (value != null) {
                //             if (row.redId != null) {
                //                 return '<label class="badge label-danger">被冲单</label>';
                //             } else if (value === 1) {
                //                 return '<label class="badge label-success">正常</label>';
                //             } else if (value === 2) {
                //                 return '<label class="badge label-danger">冲单</label>';
                //             }
                //         } else {
                //             return '--';
                //         }
                //     }
                // }
                // ,
                // {
                //     title: '操作', width: '90',
                //     formatter: function (value, row, index) {
                //         let elements = new Array();
                //         if (row.recordType === 1 && row.redId === null && row.storeType === 1 && row.sourceType === 1 && hasP('tran:semiRecord:exit')) {
                //             elements.push('<button class="btn btn-danger btn-xs" onclick="exitStore('+row.id+',this)">退库</button>');
                //         }
                //         // else if (row.recordType === 1 && row.redId === null && row.storeType === 2 && hasP('tran:semiRecord:return')) {
                //         //     elements.push('<button class="btn btn-danger btn-xs" onclick="returnStore('+row.id+',this)">返库</button>');
                //         // }
                //         // else if (row.recordType === 1 && row.redId === null && row.storeType === 3 && hasP('tran:semiRecord:transferReturn')) {
                //         //     elements.push('<button class="btn btn-danger btn-xs" onclick="transferReturnStore('+row.id+',this)">划拨返库</button>');
                //         // }
                //         return elements.join('');
                //     }
                // }
            ]
        });
        /**
         * 表格搜索
         */
        $("#btn-search").click(function () {
            js.table.search(table);
        });
    });

    /**
     *  退库
     */
    function exitStore(id, obj) {
        $(obj).attr('disabled', 'disabled');
        js.post({
            url: ctx + "transposition/halfStoreRecord/exitStore",
            data: {id: id},
            success: function (result) {
                if (result.type === web_status.SUCCESS) {
                    js.modal.success(result.msg);
                } else {
                    js.modal.warning(result.msg);
                }
                js.table.refresh(table);
                $(obj).removeAttr('disabled');
            }
        })
    }
</script>
</body>
</html>